package demo6;

public class Test {
    public static void main(String[] args) {
        String str = "asdf";
        System.out.println(str);
    }
    public static void main4(String[] args) {
        String str = String.valueOf(99);
        System.out.println(str);

        //字符串转数字
        int i = Integer.parseInt(str);
        System.out.println(i);
        double v = Double.parseDouble(str);
        System.out.println(v);
    }
    public static void main3(String[] args) {
        String str1 = "asdf";
        char ch = str1.charAt(0);
        System.out.println(ch);

        System.out.println(str1.indexOf('c'));
        System.out.println(str1.indexOf("sd"));
    }
    public static void main2(String[] args) {
        String str1 = new String("hello");
        String str2 = new String("hello");
        System.out.println(str1 == str2);  //false

        //用来比较两个引用  所指向的对象当中的内容是否一致
        System.out.println(str1.equals(str2));//true  equals

        //大于的话 返回一个整数  小于返回一个负数 相等返回0
        System.out.println(str1.compareTo(str2));
    }
    public static void main1(String[] args) {
        char[] chars = {'a','b','c'};
        String str = new String(chars);
        System.out.println(str); //abc

        char[] chars1 = new char[]{'e','r','t'};
        String str1 = new String(chars1);
        System.out.println(str1);//ert

        String str2 = "";
       // System.out.println(str2.isEmpty());  true  判断字符串是否为空
       // System.out.println(str2.length());  0     长度为0

        String str3= null;
        //System.out.println(str3.isEmpty());  空指针异常
    }
}
